namespace Eno.Domain.Entity.Event;

public abstract class AggregateRoot : EntityBase
{
    private readonly List<DomainEvent> _domainEvents = new List<DomainEvent>();

    public IReadOnlyCollection<DomainEvent> DomainEvents => _domainEvents.AsReadOnly();
    //? 添加事件
    protected void AddDomainEvent(DomainEvent domainEvent)
    {
        _domainEvents.Add(domainEvent);
    }
    //? 清除事件
    public void ClearDomainEvents()
    {
        _domainEvents.Clear();
    }
}